{extend name="property/public/insidePageBase" /}
{block name="title"}新建流程配置{/block}
{block name="body"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form  layui-form-pane">
            <div class="layui-row">
                <div class="layui-col-xs5">
                    <div class="layui-form-item">
                        <label class="layui-form-label">流程分类</label>
                        <div class="layui-input-block">
                            <select name="is_type" lay-filter="is_type" lay-search>
                                <option value="">--请选择--</option>
                                {foreach $isTypeData as $k=>$v}
                                <option value="{$k}">{$v}</option>
                                {/foreach}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-col-xs7">
                    <div class="layui-form-item">
                        <label class="layui-form-label">流程类型</label>
                        <div class="layui-input-block" id="flow_type_show">
                            <input type="text" name="flow_type" placeholder="请选择流程分类" disabled id="product-room-data" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">汇 报 给</label>
                <div class="layui-input-block">
                    <input type="text" name="accept_uids" id="accept_uids_case" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">抄 送 给</label>
                <div class="layui-input-block">
                    <input type="text" name="copy_uids" id="copy_uids_case" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item" pane="">
                <label class="layui-form-label">启用状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="is_show" autocomplete="off" value="1" title="启用">
                    <input type="radio" name="is_show" autocomplete="off" value="2" title="关闭">
                </div>
            </div>
            <div class="layui-form-item" id="audit_type" style="display: none;"  pane="">
                <label class="layui-form-label">审批方式</label>
                <div class="layui-input-block">
                    <input type="radio" name="audit_type" autocomplete="off" value="1" title="顺序审批">
                    <input type="radio" name="audit_type" autocomplete="off" value="2" title="随机审批">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注说明</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入备注说明"  name="remark" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <button class="layui-btn" lay-submit lay-filter="submitBtn" id="submitBtn">提交</button>
            </div>
        </div>
    </div>
</div>
<script id="flow_type_tpl" type="text/html">
    <select name="flow_type" lay-filter="flow_type" id="flow_type">
        <option value="">--请选择费用类别--</option>
        {{# layui.each(d.flowTypeList, function(index, elem) { }}
        <option value="{{index}}">{{elem}}</option>
        {{# }) }}
    </select>
</script>
{/block}
{block name="js"}
{__block__}
<script>
    layui.use([ 'form', 'layer','layCascader','laytpl'], function () {
        var form = layui.form,layer = layui.layer,$ = layui.$, layCascader = layui.layCascader,laytpl = layui.laytpl;
        form.on('select(is_type)', function(res) {
            let value = res.value
            if(value == 2) {
                $('#audit_type').show()
            } else {
                $('#audit_type').hide()
            }
            loadFlowTypeList(value)
        })
        function loadFlowTypeList(isType) {
            $.get('{:request()->url()}', {isType:isType,get_type:'typeData'}, function(res) {
                if(res.code == 0) {
                    var getTpl = document.getElementById('flow_type_tpl').innerHTML; // 获取模板字符
                    var elemView = document.getElementById('flow_type_show'); // 视图对象
                    laytpl(getTpl).render({flowTypeList:res.data}, function(str){
                        elemView.innerHTML = str;
                        form.render('select')
                    });
                }
            })
        }
        let accept_uids_case = layCascader({
            elem: '#accept_uids_case',
            options: {:json_encode($propertyUsersData,JSON_UNESCAPED_UNICODE)},
                props: {multiple: true }
            });
        let copy_uids_case = layCascader({
            elem: '#copy_uids_case',
            options: {:json_encode($propertyUsersData,JSON_UNESCAPED_UNICODE)},
            props: {multiple: true }
        });

    });
</script>
{/block}